package flc.ast.adapter;

import android.graphics.Color;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import flc.ast.bean.MyDocTypeBean;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;

public class DocTypeAdapter extends StkProviderMultiAdapter<MyDocTypeBean> {

    public DocTypeAdapter() {
        addItemProvider(new StkSingleSpanProvider(126));
        addItemProvider(new DocTypeProvider());
    }

    private class DocTypeProvider extends BaseItemProvider<MyDocTypeBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_doc_type;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, MyDocTypeBean bean) {
            baseViewHolder.setText(R.id.tvDocTypeItemName, bean.getName());
            if (bean.isSelected()){
                baseViewHolder.setBackgroundColor(R.id.llDocTypeItem, Color.parseColor("#478BFF"));
            }else {
                baseViewHolder.setBackgroundColor(R.id.llDocTypeItem, Color.parseColor("#4DFFFFFF"));
            }
        }
    }

}
